using Core.SimpleTemp.Common;
using Core.SimpleTemp.Common.PagingQuery;
using Core.SimpleTemp.Entitys;
using Core.SimpleTemp.Repositories;
using Core.Toolkit.Common;
using Core.Toolkit.Core;
using Core.Toolkit.Core.Api;
using Core.Toolkit.Core.Application;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Core.SimpleTemp.Application
{
    [AutoDi()]
    public class CBS_ExamRecordService : BaseAppService<CBS_ExamRecordDto, CBS_ExamRecord, CBS_ExamRecordRepository>
    {
        readonly ExcelHelp _excelHelp;
        public CBS_ExamRecordService(CBS_ExamRecordRepository repository, ExcelHelp excelHelp) : base(repository)
        {
            _excelHelp = excelHelp;
        }

        private LoadPageOffsetModelAuto<CBS_ExamRecord, CBS_ExamRecordDto> GetLoadPageOffsetMode(PagingModel<CBS_ExamRecordDto> pagingQueryModel)
        {
            var loadPageOffsetModel = this.GetLoadPageOffsetModelAuto(pagingQueryModel);
            var baseQuery = _repository.QueryBase().AsNoTracking().Include(a => a.CBS_List).Include(a => a.CBS_TrainRecord).Include(a=>a.CBS_User);//.Include(a => a.CBS_Course)
            //loadPageOffsetModel.QueryWhere = this.CreateQRList()
            //.Add("CBSCourseId", "=")
            //.Add("CBSExamQuestionsId", "=")
            //.Add("ExaminationDate", "=")
            //.Add("ExaminationType", "=")
            //.Add("DegreeOfDifficulty", "=")
            //.Add("Examiner", "=")
            //.Add("Fraction", "=")
            //.Add("CBSListId", "=")
            //.Add("IsPass", "=")
            //.Add("Annex", "=")
            //.Add("Remarks", "=")
            //.Add("CreateFactory", "=")
            //.Add("CreateDept", "=")
            //.Add("UpdateDept", "=");
            loadPageOffsetModel.BasqQuery = baseQuery;
            //loadPageOffsetModel.Order = orderModel => orderModel.CreateTime;
            //loadPageOffsetModel.Selector = model => new CBS_ExamRecord()
            //{
            //    Id = model.Id,
            //    CBSCourseId = model.CBSCourseId,
            //    CBSExamQuestionsId = model.CBSExamQuestionsId,
            //    ExaminationDate = model.ExaminationDate,
            //    ExaminationType = model.ExaminationType,
            //    DegreeOfDifficulty = model.DegreeOfDifficulty,
            //    Examiner = model.Examiner,
            //    Fraction = model.Fraction,
            //    CBSListId = model.CBSListId,
            //    IsPass = model.IsPass,
            //    Annex = model.Annex,
            //    Remarks = model.Remarks,
            //    CreateFactory = model.CreateFactory,
            //    CreateDept = model.CreateDept,
            //    UpdateDept = model.UpdateDept,
            //};
            return loadPageOffsetModel;
        }


        public async Task<IPageModel<CBS_ExamRecordDto>> GetList(PagingModel<CBS_ExamRecordDto> pagingQueryModel)
        {
            var loadPageOffsetModel = GetLoadPageOffsetMode(pagingQueryModel);
            return await base.LoadPageOffsetAsync(loadPageOffsetModel);
        }

    }

}
